package com.rzgeo.rzmaplib.model;

import android.content.Context;

import java.io.File;
import java.util.ArrayList;

/**
 * Created by zhanghang on 2018/1/20.
 */

public class RmlPrjsSet {

    private RmlPrj[] _prjs;

    public RmlPrjsSet(File dir, Context context){

        File[] fs = dir.listFiles();
        ArrayList<RmlPrj>files = new ArrayList<>(fs.length);
        for(File f:fs){
            if(RmlPrj.isVaild(f))
                files.add(new RmlPrj(f, context));
        }
        _prjs=files.toArray(new RmlPrj[0]);
    }

    public RmlPrj[]getPrjs(){
        return _prjs;
    }

    public RmlPrj getPrj(String name)
    {
        for(RmlPrj prj:_prjs){
            if(prj.getName().equalsIgnoreCase(name))
                return prj;
        }
        return null;
    }
}
